package com.abl.test;

import com.abl.tomcat.util.LogKit;

import java.io.PrintWriter;
import java.net.Socket;

/**
 * 客户端测试代码
 */
public class Client {

    public static void main(String[] args) {
        //        InetAddress address = InetAddress.getByName("127.0.0.1");
        //        Socket client2 = new Socket("127.0.0.1", 8090,address, 9999);
        Socket client1 = null;
        PrintWriter writer = null;

        try {
            client1 = new Socket("127.0.0.1", 8090);

            writer = new PrintWriter(client1.getOutputStream());

            writer.print("客户端：Hello");

            writer.flush();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {

            if (writer != null) {
                try {
                    LogKit.info(writer.toString());
                    writer.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            if (client1 != null) {
                try {
                    LogKit.info(client1.toString());
                    client1.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

    }

}
